/*
 * Copyright (c) 2020, 2023, 3044483124@qq.com All rights reserved.
 *
 */
package itcast;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>Project: JavaStudy - TimeDateDemo
 * <p>Powered by jiangbo On 2023-02-01
 * 20:48:25
 * <p>Created by IntelliJ IDEA
 *
 * @author jiangbo [3044483124@qq.com]
 * @version 1.0
 * @since 8/17
 */
public class TimeDateDemo {
    public static void main(String[] args) {
//基本类型，是直接声明变量
        int i = 3;
//1 实例化 Date()对象 年月日 时分秒 毫秒y m d h m s ms
        Date d = new Date();
        System.out.printf("%tF %<tT %<tA %n",d);
//2 通过date类获取时间戳
        long t = d.getTime();
        System.out.println(t);
        System.out.println(System.currentTimeMillis());
        //3 date实例的常用方法
        int date = d.getDate();
        System.out.println(date);
        d.getYear();
        d.getMonth();
        d.getDate();
        d.getDate();
        d.getHours();
        d.getMinutes();
        d.getSeconds();
        d.setTime(0);
        System.out.printf("%tF %<tT %<tA %n",d);
//java.util.Date 类的格式化类 SimpleDateFormat
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss E");
        System.out.println(sdf.format(new Date()));
    }

}


